package com.bidevalution.controller.api;

import com.bidevalution.business.service.SmsSendService;
import com.bidevalution.support.context.SmsTemplateCode;
import com.ggzy.tongyi.dubbo.api.EnterPriseInfoDubboService;
import com.qtp.core.model.Response;
import com.qtp.core.util.DateUtil;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * @author shenh@glodon.com
 * @date 2019-07-09 10:18
 */
@Log4j2
@Controller
public class SmsSendController extends BaseController{

    @Autowired
    private SmsSendService smsSendService;
    @Autowired
    private EnterPriseInfoDubboService enterPriseInfoDubboService;

    /**
     * 解密成功发送短信
     * @param sectionId 标段Id
     * @return
     */
    @RequestMapping(value = "/sendDecryptSuccessInfo", method = RequestMethod.POST)
    @ResponseBody
    public void sendDecryptSuccessInfo(@RequestParam("sectionId")String sectionId,@RequestParam("orgCode")String orgCode) {
        try {
            Map<String, Object> params = new HashMap<>();
            params.put("ep_org_code", orgCode);
            // 获取请求中的参数
            Response<Map<String, Object>> response = enterPriseInfoDubboService.getEnterInfo(params);
            String phones = (String)response.getResult().get("ep_contact_mphone");
            smsSendService.sendMsg(SmsTemplateCode.kb0006.getValue(), phones, null);
        } catch (Exception e) {
            log.error(e.getMessage());
        }
    }
}
